package cn.stylefeng.guns.modular.business.frequency.cmcompanyline.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.cmcompanyline.service.CmCompanyLineService;
import cn.stylefeng.guns.modular.business.frequency.cmcompanyline.model.param.CmCompanyLineParam;

import javax.annotation.Resource;

/**
 * 客户线路表 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class CmCompanyLineController {

    @Resource
    private CmCompanyLineService cmCompanyLineService;

    /**
     * 分页查询客户线路表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCompanyLine/page")
    @BusinessLog(title = "客户线路表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CmCompanyLineParam cmCompanyLineParam) {
        return new SuccessResponseData(cmCompanyLineService.page(cmCompanyLineParam));
    }

    /**
     * 获取全部客户线路表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCompanyLine/list")
    @BusinessLog(title = "客户线路表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CmCompanyLineParam cmCompanyLineParam) {
        return new SuccessResponseData(cmCompanyLineService.list(cmCompanyLineParam));
    }

    /**
     * 查看详情客户线路表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmCompanyLine/detail")
    @BusinessLog(title = "客户线路表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CmCompanyLineParam.detail.class) CmCompanyLineParam cmCompanyLineParam) {
        return new SuccessResponseData(cmCompanyLineService.detail(cmCompanyLineParam));
    }

    /**
     * 添加客户线路表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCompanyLine/add")
    @BusinessLog(title = "客户线路表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CmCompanyLineParam.add.class) CmCompanyLineParam cmCompanyLineParam) {
        cmCompanyLineService.add(cmCompanyLineParam);
        return new SuccessResponseData();
    }

    /**
     * 删除客户线路表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCompanyLine/delete")
    @BusinessLog(title = "客户线路表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CmCompanyLineParam.delete.class) CmCompanyLineParam cmCompanyLineParam) {
        cmCompanyLineService.delete(cmCompanyLineParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑客户线路表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmCompanyLine/edit")
    @BusinessLog(title = "客户线路表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CmCompanyLineParam.edit.class) CmCompanyLineParam cmCompanyLineParam) {
        cmCompanyLineService.edit(cmCompanyLineParam);
        return new SuccessResponseData();
    }


}
